package com.itqf.service.impl;

import com.itqf.mapper.DtsPermissionMapper;
import com.itqf.service.DtsPermissionService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Set;

/**
 * projectName: sm_project
 *
 * @author: 赵伟风
 * time: 2021/7/13 14:27
 * description:
 */
@Service
public class DtsPermissionServiceImpl implements DtsPermissionService {

    @Autowired
    private DtsPermissionMapper dtsPermissionMapper;

    public static final Logger logger = LoggerFactory.getLogger(DtsPermissionServiceImpl.class);

    /**
     * 如果不同角色有相同的权限!
     * 返回的权限集合,会出现重复的权限!
     * 考虑去重复!
     * 根据用户id查询权限信息
     *
     * @param roleIds 根据角色id数组查询!
     * @return
     */
    @Override
    public Set<String> queryPermissionNames(Integer[] roleIds) {

        //1.判断参数
        if (roleIds == null || roleIds.length == 0) {
            logger.warn("[权限查询业务]roleIds数组为null!");
            return null;
        }

        //2.调用数据库
        Set<String> permissions  = dtsPermissionMapper.queryPermissionByRoleIds(roleIds);
        //3.处理返回结果

        return permissions;
    }
}
